package com.decent.ejfadmin.common.bean;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 产品信息
 *
 * @author zhangchao
 * @date 2018/7/25 9:09
 */
@Data
public class SupplyProduct implements Serializable {
    private static final long serialVersionUID = 6455209848065542426L;

    private Long id;

    private String productName;

    private Integer productType;

    private String area;

    private Double face;

    private Integer type;

    private Integer state;

    private Date modified;

    private String admin;
    /**
     * 产品编号
     */
    private String cardProductId;
    /**
     * 第三方id
     */
    private String thirdId;
    /**
     * 上传方式 0是非卡密，1是卡密, 2是二维码+链接
     */
    private Integer submitType;
    /**
     * 卡号卡密校验规则( 卡号/卡密;卡号/卡密 )
     */
    private String cardRestrict;

    /**
     * 运营商名称
     */
    private String cardOperatorName;
    /**
     * 闲鱼卡券Spu
     */
    private Integer ticketSpuid;
    /**
     * 闲鱼卡券Spu状态
     */
    private Integer spuStatus;
    /**
     * 备注
     */
    private String remark;

    public MessageBean check() {
        if (StringUtils.isBlank(productName)) {
            return MessageBean.fail("产品名称必填!");
        }
        if (StringUtils.isBlank(cardProductId)) {
            return MessageBean.fail("产品Id必填!");
        }
        if (productType == null) {
            return MessageBean.fail("运营商必选!");
        }
        if (StringUtils.isBlank(area)) {
            return MessageBean.fail("地区必填!");
        }
        if (face == null || face <= 0) {
            return MessageBean.fail("请输入正确的面值!");
        }
        if (state == null) {
            return MessageBean.fail("状态必选!");
        }
        if (submitType == null) {
            return MessageBean.fail("提交方式必填!");
        }
        if (Integer.valueOf(1).equals(submitType) && StringUtils.isBlank(cardRestrict)) {
            return MessageBean.fail("提交方式为卡密校验规则必填!");
        }
        return null;
    }
}
